<!DOCTYPE html>
<html>
<meta charset="utf-8"> 
<head>
	<title data-localize="backcheck.title">背检</title>
<link rel="stylesheet" type="text/css" href="css/common.css">
<style type="text/css">
body{
	margin: 0;
	padding: 0;
}
p{
	margin: 0;
}
.u-line{
	margin: 0 auto;
	width: 890px;
    height: 600px;
    overflow: hidden;
}
.u-road{
	position: relative;
	height: 200px;
	width: 1010px;
	float: right;
	margin-top: 110px;
	-webkit-transform: rotateY(180deg);
}
.u-road p{
	-webkit-transform: rotateY(180deg);
}
.u-road span{
	display: inline-block;
	-webkit-transform: rotateY(180deg);
}
.opposite{
	margin-top: 0;
	-webkit-transform: rotateX(180deg) rotateY(180deg);
}
.opposite p{
	-webkit-transform: rotateX(180deg) rotateY(180deg);
}
.opposite span{
	display: inline-block;
	-webkit-transform: rotateX(180deg) rotateY(180deg);
}
.u-roadcon{
	position: relative;
	float: left;
}
.u-roadcon:after{
	content: '';
	display: block;
	clear: both;
}
.u-road:after{
	content: '';
	display: block;
	clear: both;
}
.u-road-opposite:after{
	content: '';
	display: block;
	clear: both;
}
.u-track{
	position: absolute;
	height: 28px;
	width: 100%;
	left: 0;
	top: 85px;
	border-top: 1px solid #cecece;
	border-bottom: 1px solid #cecece;
}
.u-track2{
	position: absolute;
	height: 28px;
	width: 388px;
	left: 190px;
	top: -15px;
	border: 1px solid #cecece;
}
.u-outtrack{
	position: absolute;
	height: 70px;
	width: 28px;
	left: 550px;
	top: 15px;
	border-left: 1px solid #cecece;
	border-right: 1px solid #cecece;
}

.u-upbox{
	position: absolute;
	left: 170px;
    top: -35px;
    height: 70px;
    width:450px;
}
.u-upbox .u-boxcon{
	margin: 0;
	margin-right: 50px;
}
.u-upbox .u-boxcon:last-child{
	margin: 0;
}
.u-box{
	position: absolute;
	left: 0px;
	top: 0px;
	background: #bdcee2;
    width: 68px;
    height: 68px;
    border-radius: 4px;
    z-index: 10;
}
.u-boxcon p{
	margin: 0;
	padding: 0;
	position: absolute;
	top: -20px;
	line-height: 20px;
	font-size: 14px;
	color: #484848;
	width: 69px;
	text-align: center;
}
.break{
	background: url('image/break.png') no-repeat 0 0;
	background-size: 100% 100%;
}
.u-btns{
	margin: 20px 0 0 60%;
}
.u-input{
	position: absolute;
	left: 650px;
	top: 65px;
	width: 68px;
	height: 68px;
	background: #b9b9b9;
	border-radius: 4px;
	border: 1px solid #29abe2;
	z-index: 10;
	text-align: center;
	line-height: 68px;
}
.u-output{
	position: absolute;
	left: 530px;
	top: -35px;
	width: 68px;
	height: 68px;
	background: #eef2f7;
	border-radius: 4px;
	border: 1px solid #29abe2;
	z-index: 2;
	text-align: center;
	line-height: 68px;
}
.u-cache{
	position: absolute;
	left: 170px;
	top: -35px;
	width: 68px;
	height: 68px;
	background: #eef2f7;
	border-radius: 4px;
	border: 1px solid #29abe2;
	z-index: 10;
}
.u-cache p{
	margin: 0;
	text-align: center;
	font-size: 10px;
	margin-top: 4px;
}
.u-check{
	position: relative;
	float: left;
	width: 68px;
	height: 68px;
	margin: 65px 85px 65px 50px;
	background: #bdcee2;
	border-radius: 4px;
	border: 1px solid #29abe2;
	line-height: 70px;
	text-align: center;
	z-index: 10;
}
.u-checkbegin{
	margin-left: 85px;
}
/*animations*/
.moveleft{
	-webkit-animation: moveleft 0.3s linear infinite;
}
.moveup{
	-webkit-animation: moveup 0.3s ease infinite;
}
.movedown{
	-webkit-animation: movedown 0.3s ease infinite;
}
@-webkit-keyframes moveleft {
0%{
	-webkit-transform: translateX(0);
}
100%{
	-webkit-transform: translateX(-115px);
}
}
@-webkit-keyframes moveup {
0%{
	-webkit-transform: translateY(0);
}
20%{
	-webkit-transform: translateY(0);
}
100%{
	-webkit-transform: translateY(-99px);
}
}
@-webkit-keyframes movedown {
0%{
	-webkit-transform: translateY(0);
}
20%{
	-webkit-transform: translateY(0);
}
100%{
	-webkit-transform: translateY(99px);
}
}
.stop {
    animation-play-state: paused;
}
.u-adjust{
	position: absolute;
	left: 770px;
	width: 71px;
	height: 20px;
}
</style>
</head>
<body>
<div class='u-head'>
   <div class="u-headcon">
	<a href="index.html"><div class="u-mainpage" data-localize="back">回到首页</div></a>
	<h3 data-localize="backcheck.title">背检</h3>
	<div class="changeLang">
		<p class="u-lang"><span>中文</span><span>English</span></p>
	    <div isopen="true" class="changeLangBtn"></div>
	</div>
</div>
</div>
<div class="u-infos">
	<h2 data-localize="backcheck.info_title">状态区域</h2>
	<div class="u-errorlist">
		<h3 data-localize="yichang">异常一览：</h3>
		<div class="u-errorlistcon">
		</div>
	</div>
	<p class="status"><span data-localize="backcheck.running">运行状态：</span><span class="u-cube t-status"></span></p>
</div>
<div class="t-con">
<div class="u-line">
	<div class="u-boxcon needleft u-boxconspe" id="u-boxe"><div class="u-box u-boxe"></div></div>
	<div class="u-road mainroad lineA">
		<div class="u-adjust u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-track"></div>
		<div class="u-track2"></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box9"><p></p></div></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box8"><p></p></div></div>
		<div class="u-upbox">
			<div class="u-boxcon needdown stop" id="needdown"><div class="u-box u-box7"><p></p></div></div>
			<div class="u-boxcon needleft stop"><div class="u-box u-box6"><p></p></div></div>
			<div class="u-boxcon needleft stop"><div class="u-box u-box5"><p></p></div></div>
			<div class="u-boxcon needleft stop"><div class="u-box u-box4"><p></p></div></div>
		</div>
		<div class="u-check"><p data-localize="backcheck.checkbox">背检</p></div>
		<div class="u-boxcon needup u-checkbegin stop" id="needup"><div class="u-box u-box3"><p></p></div></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box2"><p></p></div></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box1"><p></p></div></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box1"></div></div>
		<div class="u-outtrack"></div>
		<div class="u-outtrack" style="left: 190px;"></div>
	</div>
	<div class="u-road lineB">
		<div class="u-adjust u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-track"></div>
		<div class="u-track2"></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box9"><p></p></div></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box8"><p></p></div></div>
		<div class="u-upbox">
			<div class="u-boxcon needdown stop" id="needdown-b"><div class="u-box u-box7"><p></p></div></div>
			<div class="u-boxcon needleft stop"><div class="u-box u-box6"><p></p></div></div>
			<div class="u-boxcon needleft stop"><div class="u-box u-box5"><p></p></div></div>
			<div class="u-boxcon needleft stop"><div class="u-box u-box4"><p></p></div></div>
		</div>
		<div class="u-check"><p data-localize="backcheck.checkbox">背检</p></div>
		<div class="u-boxcon needup u-checkbegin stop" id="needup-b"><div class="u-box u-box3"><p></p></div></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box2"><p></p></div></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box1"><p></p></div></div>
		<div class="u-boxcon needleft stop"><div class="u-box u-box1"></div></div>
		<div class="u-outtrack"></div>
		<div class="u-outtrack" style="left: 190px;"></div>
	</div>
</div>
</div>
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/language_cookie.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var lastData = null,
	si=null,
	isFirst = true;
var url = getUrl("backcheck");
var request = new GetRequest();
var showval= request.type; 
if ('WebSocket' in window) {
    websocket = new WebSocket(url+'/'+request.line+'/'+request.index);
}else {
    alert('Not support websocket')
}
if (request.line == "A") {
	$('.lineB').hide();
	$('.lineA').show();
}else if (request.line == "B") {
	$('.lineA').hide();
	$('.lineB').show();
}
websocket.onerror = function () {
    $('.u-boxcon').addClass('stop');
	$('.u-handbar').addClass('stop');
    $('.u-box4').addClass('stop');
    $('.u-box3').addClass('break');
};

websocket.onopen = function (event) {
    $('.u-boxcon').removeClass('stop');
	$('.u-handbar').removeClass('stop');
    $('.u-box4').removeClass('stop');
    $('.u-box3').removeClass('break');
}
function addanimate(obj){
    for (var i = 0; i < obj.length; i++) {
       (function(i){
            if (obj[i].isPause == 0){
               if (obj[i].stack_index == 3) {
               	$('.u-box'+obj[i].stack_index).parent().addClass('moveup');
               }else if (obj[i].stack_index == 7) {
               	$('.u-box'+obj[i].stack_index).parent().addClass('movedown');
               }else{
               	$('.u-box'+obj[i].stack_index).parent().addClass('moveleft');
               }
            }
       })(i); 
    }
}
websocket.onmessage = function (event) {
	si = JSON.parse(event.data.replace(/\bNaN\b/g, "null"));
	$('#u-boxe').addClass('moveleft');
    if (!lastData) {
    	lastData = si;
    }
    if (si.isPause1 == 0) {
    	$('.u-adjusttop').addClass('u-adjustup');
    	$('.u-adjustbottom').addClass('u-adjustdown');
    }else if (si.isPause1 == 1) {
    	$('.u-adjusttop').removeClass('u-adjustup');
    	$('.u-adjustbottom').removeClass('u-adjustdown');
    }
	changeColor($('.t-status'),si.p2);
	errorRender();
	addanimate(si.stack_list);
    if (isFirst) {
    	count(si.stack_list,4);
		isFirst = false;
    }
    console.log(si);
    lastData = si;
    
}


document.getElementById('u-boxe').addEventListener("webkitAnimationIteration", function(){
	reset();
	count(si.stack_list,4);
    $('.needleft').removeClass('moveleft');

}, false);
document.getElementById('needup').addEventListener("webkitAnimationIteration", function(){
    $('.needup').removeClass('moveup');
}, false);
document.getElementById('needdown').addEventListener("webkitAnimationIteration", function(){
    $('.needdown').removeClass('movedown');
}, false);
document.getElementById('needup-b').addEventListener("webkitAnimationIteration", function(){
    $('.needup').removeClass('moveup');
}, false);
document.getElementById('needdown-b').addEventListener("webkitAnimationIteration", function(){
    $('.needdown').removeClass('movedown');
}, false);
window.onbeforeunload = function(){
	websocket.close();
}  
</script>
</body>
</html>